home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / programm.ing / progem.lzh / gemcl3.c < prev    next >
Encoding:
Text File  |  1986-07-16  |  2.0 KB  |  112 lines

  1. /*
  2. >>>>>>>>>>>>>>>>>>>>>>> Basic Dialog Handler <<<<<<<<<<<<<<<<<<<<<<<
  3. */
  4.  
  5. WORD
  6. hndl_dial(tree, def, x, y, w, h)
  7. LONG    tree;
  8. WORD    def;
  9. WORD    x, y, w, h;
  10. {
  11.     WORD    xdial, ydial, wdial, hdial, exitobj;
  12.  
  13.     form_center(tree, &xdial, &ydial, &wdial, &hdial);
  14.     form_dial(0, x, y, w, h, xdial, ydial, wdial, hdial);
  15.     form_dial(1, x, y, w, h, xdial, ydial, wdial, hdial);
  16.     objc_draw(tree, ROOT, MAX_DEPTH, xdial, ydial, wdial, hdial);
  17.     exitobj = form_do(tree, def) & 0x7FFF;
  18.     form_dial(2, x, y, w, h, xdial, ydial, wdial, hdial);
  19.     form_dial(3, x, y, w, h, xdial, ydial, wdial, hdial);
  20.     return (exitobj);
  21. }
  22.  
  23. /*
  24. >>>>>>>>>>>>>>>>>>>>>>> Object rectangle utility <<<<<<<<<<<<<<<<<<<<<<<<<
  25. */
  26.  
  27. VOID
  28. objc_xywh(tree, obj, p)        /* get x,y,w,h for specified object    */
  29. LONG    tree;
  30. WORD    obj;
  31. GRECT    *p;
  32. {
  33.     objc_offset(tree, obj, &p->g_x, &p->g_y);
  34.     p->g_w = LWGET(OB_WIDTH(obj));
  35.     p->g_h = LWGET(OB_HEIGHT(obj));
  36. }
  37.  
  38. /*
  39. >>>>>>>>>>>>>>>>>>>>>>> Object flag utilities <<<<<<<<<<<<<<<<<<<<<<<<<<<
  40. */
  41.  
  42. VOID
  43. undo_obj(tree, which, bit)    /* clear specified bit in object state    */
  44. LONG    tree;
  45. WORD    which, bit;
  46. {
  47.     WORD    state;
  48.  
  49.     state = LWGET(OB_STATE(which));
  50.     LWSET(OB_STATE(which), state & ~bit);
  51. }
  52.  
  53. VOID
  54. desel_obj(tree, which)        /* turn off selected bit of spcfd object*/
  55. LONG    tree;
  56. WORD    which;
  57. {
  58.     undo_obj(tree, which, SELECTED);
  59. }
  60.  
  61. VOID
  62. do_obj(tree, which, bit)    /* set specified bit in object state    */
  63. LONG    tree;
  64. WORD    which, bit;
  65. {
  66.     WORD    state;
  67.  
  68.     state = LWGET(OB_STATE(which));
  69.     LWSET(OB_STATE(which), state | bit);
  70. }
  71.  
  72. VOID
  73. sel_obj(tree, which)        /* turn on selected bit of spcfd object    */
  74. LONG    tree;
  75. WORD    which;
  76. {
  77.     do_obj(tree, which, SELECTED);
  78. }
  79.  
  80. BOOLEAN
  81. statep(tree, which, bit)
  82. LONG    tree;
  83. WORD    which;
  84. WORD    bit;
  85. {
  86.     return ( (LWGET(OB_STATE(which)) & bit) != 0);
  87. }
  88.  
  89. BOOLEAN
  90. selectp(tree, which)
  91. LONG    tree;
  92. WORD    which;
  93. {
  94.     return statep(tree, which, SELECTED);
  95. }
  96.  
  97. /*
  98. >>>>>>>>>>>>>>>>>>>>>> Sample radio buttons after dialog <<<<<<<<<<<<<<<<<<<<
  99. */
  100.  
  101.  
  102. WORD
  103. encode(tree, ob1st, num)
  104. LONG    tree;
  105. WORD    ob1st, num;
  106. {
  107.     for (; num--; )
  108.         if (selectp(ob1st+num))
  109.             return(num);
  110.     return (-1);
  111. }
  112.